/**
 * Created by asus on 2017/5/5.
 */
import http from '../../../common/httpUtil'
import * as types from './mutationTypes'

const actions = {
  queryWebNews({commit}, {index = 1, size = 10} = {}) {
    commit(types.SPIDER_QUERY_WEBNEWS_BEGIN)
    let url = `sys/webNews?page=${index}&size=${size}`;
    return http.getRaw(url).then(result => {
      let webNews = result.body.objs;
      let currentPage = result.body.page;
      let totalCount = result.body.totalNum;
      console.log(webNews)
      commit(types.SPIDER_QUERY_WEBNEWS_SUC, {webNews, currentPage, totalCount});
    })
  },
  searchWebNews({commit}, {searchText, index = 1, size = 10} = {}) {
    /*
    let url = `sys/news/search?keyword=${searchText}&page=${index}&size=${size}`;
    return http.getRaw(url).then(result => {
      let news = result.body.objs;
      let currentPage = result.body.page;
      let totalCount = result.body.totalNum;
      commit(types.SPIDER_SEARCH_NEWS_SUC, {news, currentPage, totalCount});
    });
    */
  },
  queryWebsiteList({commit}, {index = 1, size = 10} = {}) {
    commit(types.SPIDER_QUERY_WEBSITELIST_BEGIN);
    let url = '';
    return http.getRaw(url).then(result => {
      let webNews = result.body.objs;
      let currentPage = result.body.page;
      let totalCount = result.body.totalNum;
      console.log(webNews)
      commit(types.SPIDER_QUERY_WEBSITELIST_SUC, {webNews, currentPage, totalCount});
    })
  }
}
export default actions
